package cn.supermaster.management.web.controller.system;

import cn.supermaster.management.common.controller.BaseController;
import cn.supermaster.management.web.service.system.ISCaptchaService;
import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Producer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 图片验证码（支持算术形式）
 */
@Controller
@RequestMapping("/captcha")
public class SystemCaptchaController extends BaseController {

    @Autowired
    private ISCaptchaService captchaService;

    @GetMapping(value = "/captchaImage")
    public ModelAndView getKaptchaImage(HttpServletRequest request, HttpServletResponse response) {
        return captchaService.doCreateKaptchaImage(request, response);
    }
}